<template>
	<view class="footer">
		<view class="nav">
			<button class="navItem" open-type="contact">
				<image
					src="https://img.js.design/assets/img/658598fa4d644979c8241211.png#00554c4a3178c529e95d3017bfd2ff40"
					mode=""></image>
				<text>客服</text>
			</button>
			<button class="navItem" open-type="share">
				<image src="@/static/eIcones/分享.png" mode=""></image>
				<text>分享</text>
			</button>
		</view>
		<view class="but" @click="openSucceedPopup">
			<text>提交咨询</text>
		</view>
	</view>
	<uni-popup ref="successPopup" type="bottom" animation="true" :is-mask-click="false" :mask-click="false">
		<view class="popup-content">
			<view class="icon-box">
				<uni-icons type="checkbox" size="60"></uni-icons>
			</view>
			<text class="title">咨询单下单成功,待客服联系 </text>
			<text class="content">西望顾问将在三天内联系您确认具体旅行方案,请保持联系</text>
			<!-- <text class="content">您可以到'我的--咨询订单'查看订单</text> -->
			<view class="confirm" @click="closeSucceedPopup">我知道了</view>
		</view>
	</uni-popup>
</template>

<script setup>
	import {
		ref,
		defineEmits,
		watchEffect
	} from 'vue';
	import {
		orderBackPost
	} from '@/config/API/Customize.js'
	const emit = defineEmits();
	const successPopup = ref(null);
	const propos = defineProps({
		TripData: {
			type: Object,
			default: () => {},
		},
	})
	watchEffect(() => {});
	const openSucceedPopup = async () => {
		uni.showLoading({
			title: '正在创建',
			mask: 'true'
		})
		try {
			const resPost = await orderBackPost(propos.TripData)
			if (resPost.code == 200) {
				emit('openSucceedPopup');
				successPopup.value.open('center');
				uni.hideLoading()
			} else {
				uni.showToast({
					title: '订单异常请稍后再试',
					icon: 'error'
				});
				uni.hideLoading()
			}
		} catch (e) {
			//TODO handle the exception
			uni.showToast({
				title: '服务器异常',
				icon: 'error'
			})
			uni.hideLoading()
		}


	};

	const closeSucceedPopup = () => {
		emit('closeSucceedPopup');
		successPopup.value.close();
		uni.reLaunch({
			url: '/pages/home/index'
		})
	};
</script>

<style lang="scss" scoped>
	.footer {
		width: 100%;
		height: 130rpx;
		background-color: #fff;
		position: fixed;
		bottom: 0rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 20rpx 40rpx;
		padding-bottom: 30rpx;
		box-sizing: border-box;
		border-top: 2rpx solid #f5f6f7;

		.nav {
			display: flex;
			gap: 60rpx;
			justify-content: center;
			align-items: center;

			.navItem {
				line-height: 40rpx;
				display: flex;
				flex-direction: column;
				align-items: center;
				justify-content: space-around;
				background-color: #fff;
				padding: 0;
				margin: 0;

				image {
					width: 40rpx;
					height: 36rpx;
				}

				text {
					font-size: 28rpx;
					color: #717171;
				}
			}

			.navItem::after {
				border: none;
			}
		}

		.but {
			display: flex;
			align-items: center;
			width: 400rpx;
			height: 100%;
			border-radius: 50rpx;
			background-color: #000;
			overflow: hidden;

			text {
				width: 100%;
				text-align: center;
				color: #fff;
			}
		}
	}

	.popup-content {
		width: 85vw;
		border-radius: 30rpx;
		background-color: #fff;
		animation: slideUp 0.3s ease-out;

		.icon-box {
			width: 100%;
			height: 180rpx;
			display: flex;
			align-items: center;
			justify-content: center;
		}

		text {
			display: block;
			text-align: center;
			padding: 50rpx 30rpx 0 30rpx;
			box-sizing: border-box;
		}

		.title {
			width: 100%;
			margin-bottom: 20rpx;
			letter-spacing: 3rpx;
			padding-top: 0;
		}

		.content {
			width: 100%;
			font-size: 26rpx;
			color: #999999;
			padding: 0rpx 30rpx 40rpx 30rpx;
			letter-spacing: 2rpx;
		}

		.confirm {
			width: 100%;
			height: 120rpx;
			border-top: 2rpx solid #f5f6f7;
			display: flex;
			justify-content: center;
			font-size: 28rpx;
			align-items: center;
		}
	}

	@keyframes slideUp {
		from {
			transform: translateY(100%);
		}

		to {
			transform: translateY(0);
		}
	}
</style>